﻿@using thousandClear.Areas.Admin.Models;
@model List<CustomerModel>

@{
    ViewBag.Title = "客户管理";
    Layout = "~/Areas/Admin/Views/Shared/_Admin.cshtml";
}
<div id="divMain" style="width:100%; position:fixed; left:0px; top:0px; z-index:99999; background-color:white; filter:alpha(opacity=80);
	-moz-opacity:0.8;
	-khtml-opacity: 0.8;
	opacity: 0.8;">

    <img src="~/Statics/Images/Activity/load.gif" style="position:fixed; width:10%; left:40%; top:40%" />
</div>
<div id="app">
    <div class="am-cf am-padding">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">后台管理</strong> / <small>@ViewBag.Title</small></div>
    </div>

    <div class="am-u-sm-12 am-u-md-2">
        <div class="am-form-group">
            <label>昵称：</label>
            <input type="text" class="am-input-sm" id="customername" />
        </div>

    </div>
    <div class="am-u-sm-12 am-u-md-2">
        <div class="am-form-group">
            <label>客户编号：</label>
            <input type="text" class="am-input-sm" id="cusnooo" />
        </div>
    </div>

    <div class="am-u-sm-12 am-u-md-12">
        <button class="am-btn am-btn-primary" onclick="searchop()">查询</button>
    </div>
    <div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                </div>
            </div>
        </div>
        <div class="am-g">
            <div class="am-u-sm-12">
                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>昵称</th>
                            <th>客户编号</th>
                            <th>积分</th>
                            <th>注册时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (CustomerModel item in Model)
                        {
                            <tr>
                                <td>@item.OCID</td>
                                <td>@item.ocNicName</td>
                                <td>@item.CreatedBy</td>
                                <td>@item.Point</td>
                                <td>@item.CreatedDate</td>
                                <td>
                                    @if (ViewBag.level != "2")
                                    {
                                        <div class="am-btn-toolbar" style="float:left; margin-left:5px;">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <a onclick="modfiy('@item.OCID-@item.ocNicName-@item.Point')" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0, width: 800, height: 600}" class="am-btn am-btn-primary am-btn-xs am-hide-sm-only"><span class="am-icon-edit"></span>修改用户</a>
                                            </div>
                                        </div>
                                    }
                                </td>
                            </tr>
                        }

                    </tbody>
                </table>
                <div class="am-cf">
                    &nbsp;&nbsp;共 @ViewBag.TotalCount 条记录, 每页 @ViewBag.PageCount 条记录
                    <div class="am-fr">
                        <ul class="am-pagination">
                            <li style="width: 60px">
                                <input class="am-form-field" style="text-align:center" type="text" v-model="gotoPage">

                            </li>
                            <li><a href="/admin/consumer?page={{gotoPage}}&count={{pageCount}}">GoTo &raquo;</a></li>

                            <li><a href="@ViewBag.PrevPageUrl">&laquo; Prev</a></li>
                            <li><span>@ViewBag.CurrentPage/@ViewBag.TotalPage</span></li>
                            <li><a href="@ViewBag.NextPageUrl">Next &raquo;</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
        <div class="am-modal-dialog" style="overflow-y:auto;">
            <div class="am-modal-hd">
                用户信息
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <div class="am-modal-bd">
                <div class="am-g">
                    <div class="am-u-sm-12">
                        <div class="am-form-group">
                            <label>用户ID：</label>
                            <span id="custID"></span>
                        </div>
                        <div class="am-form-group">
                            <label>昵称：</label>
                            <span id="custname"></span>
                        </div>
                        <div class="am-form-group">
                            <label>积分：</label>
                            <input type="text" class="am-input-sm" id="txtpoint" />
                        </div>
                    </div>
                </div>
                <div class="am-u-sm-12 am-u-md-12">
                    <button class="am-btn am-btn-primary" onclick="onSubOgr()">修改信息</button>
                </div>
            </div>
        </div>
    </div>
</div>

@section Scripts{
    <script>
        var model = new Vue({
            el: '#app',
            data: {
                pageCount: @ViewBag.PageCount,
                gotoPage: @ViewBag.CurrentPage,
            }
        });

        $('.admin-sidebar-consumer').addClass('current')

        $(function() {

            $("#divMain").css("height",$(window).height()+"px");
            closeLoading();
        });

        function showLoading(){

            $("#divMain").css("display","");
        }

        function closeLoading(){

            $("#divMain").css("display","none");
        }

        function modfiy(obj){

            $("#custID").text(obj.toString().split('-')[0]);
            $("#custname").text(obj.toString().split('-')[1]);
            $("#txtpoint").val(obj.toString().split('-')[2]);

        }

        function onSubOgr(){

            var data1 = '{"ocid":"'+$("#custID").text()+'","point":"'+$("#txtpoint").val()+'"}';

            showLoading();
            $.ajax({
                type: "POST",
                url: "../admin/Consumer/UpdateCust",
                contentType: "application/json",
                data: data1,
                success: function (responseData) {

                    closeLoading();
                    window.location.reload();

                }
            });
        }

        function searchop(){

            window.location.href = "../admin/Consumer?nickname="+ $("#customername").val() + "&cusnooo="+$("#cusnooo").val();
        }

    </script>
}

